/**
 */
package sdmakerz_v1.coresyntax.sDMakerV1.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import sdmakerz_v1.coresyntax.sDMakerV1.CombinableDiagramElement;
import sdmakerz_v1.coresyntax.sDMakerV1.Consequent;
import sdmakerz_v1.coresyntax.sDMakerV1.DoubleExp;
import sdmakerz_v1.coresyntax.sDMakerV1.SDMakerV1Package;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Consequent</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link sdmakerz_v1.coresyntax.sDMakerV1.impl.ConsequentImpl#getProbConseq <em>Prob Conseq</em>}</li>
 *   <li>{@link sdmakerz_v1.coresyntax.sDMakerV1.impl.ConsequentImpl#getConseq_elts <em>Conseq elts</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ConsequentImpl extends MinimalEObjectImpl.Container implements Consequent
{
  /**
   * The cached value of the '{@link #getProbConseq() <em>Prob Conseq</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getProbConseq()
   * @generated
   * @ordered
   */
  protected DoubleExp probConseq;

  /**
   * The cached value of the '{@link #getConseq_elts() <em>Conseq elts</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getConseq_elts()
   * @generated
   * @ordered
   */
  protected EList<CombinableDiagramElement> conseq_elts;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ConsequentImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return SDMakerV1Package.Literals.CONSEQUENT;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public DoubleExp getProbConseq()
  {
    return probConseq;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetProbConseq(DoubleExp newProbConseq, NotificationChain msgs)
  {
    DoubleExp oldProbConseq = probConseq;
    probConseq = newProbConseq;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SDMakerV1Package.CONSEQUENT__PROB_CONSEQ, oldProbConseq, newProbConseq);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setProbConseq(DoubleExp newProbConseq)
  {
    if (newProbConseq != probConseq)
    {
      NotificationChain msgs = null;
      if (probConseq != null)
        msgs = ((InternalEObject)probConseq).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SDMakerV1Package.CONSEQUENT__PROB_CONSEQ, null, msgs);
      if (newProbConseq != null)
        msgs = ((InternalEObject)newProbConseq).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SDMakerV1Package.CONSEQUENT__PROB_CONSEQ, null, msgs);
      msgs = basicSetProbConseq(newProbConseq, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, SDMakerV1Package.CONSEQUENT__PROB_CONSEQ, newProbConseq, newProbConseq));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<CombinableDiagramElement> getConseq_elts()
  {
    if (conseq_elts == null)
    {
      conseq_elts = new EObjectContainmentEList<CombinableDiagramElement>(CombinableDiagramElement.class, this, SDMakerV1Package.CONSEQUENT__CONSEQ_ELTS);
    }
    return conseq_elts;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case SDMakerV1Package.CONSEQUENT__PROB_CONSEQ:
        return basicSetProbConseq(null, msgs);
      case SDMakerV1Package.CONSEQUENT__CONSEQ_ELTS:
        return ((InternalEList<?>)getConseq_elts()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case SDMakerV1Package.CONSEQUENT__PROB_CONSEQ:
        return getProbConseq();
      case SDMakerV1Package.CONSEQUENT__CONSEQ_ELTS:
        return getConseq_elts();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case SDMakerV1Package.CONSEQUENT__PROB_CONSEQ:
        setProbConseq((DoubleExp)newValue);
        return;
      case SDMakerV1Package.CONSEQUENT__CONSEQ_ELTS:
        getConseq_elts().clear();
        getConseq_elts().addAll((Collection<? extends CombinableDiagramElement>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case SDMakerV1Package.CONSEQUENT__PROB_CONSEQ:
        setProbConseq((DoubleExp)null);
        return;
      case SDMakerV1Package.CONSEQUENT__CONSEQ_ELTS:
        getConseq_elts().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case SDMakerV1Package.CONSEQUENT__PROB_CONSEQ:
        return probConseq != null;
      case SDMakerV1Package.CONSEQUENT__CONSEQ_ELTS:
        return conseq_elts != null && !conseq_elts.isEmpty();
    }
    return super.eIsSet(featureID);
  }

} //ConsequentImpl
